package com.TestDemo.Test2;

import java.util.Deque;
import java.util.Iterator;
import java.util.LinkedList;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: zjz
 * @Date: 2021/10/21/22:35
 * @Description:
 * @Target:
 */
public class LinkedListMethodTest {
    public static void main(String[] args) {
        Deque<Integer> nums = new LinkedList<>(); // 存数据
        nums.add(1);
        nums.add(2);
        nums.add(3);
        nums.add(4);
        nums.add(5);


        Iterator<Integer> iterator = nums.iterator();
        while (iterator.hasNext()){
            Integer next = iterator.next();
            System.out.print(next+" ");
        }
        System.out.println();


        System.out.println(nums.pop());
        System.out.println(nums.pop());
        System.out.println(nums.pop());

        System.out.println();
        Iterator<Integer> iterator1 = nums.iterator();
        while (iterator1.hasNext()){
            Integer next = iterator1.next();
            System.out.print(next+" ");
        }

        System.out.println();
        nums.forEach(System.out::print);
        System.out.println();
        nums.push(1);
        nums.forEach(System.out::print);

    }
}
